<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>属性选择器</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        div {
            padding: 0 3px;
            margin: 1px 0;
        }

        div[title] {
            /* 选取具有某属性的元素，如title、id、class */
            color: darkcyan;
        }

        div[title="yyy"] {
            /* 选取具有特定属性值的元素 */
            font-size: 30px;
        }

        div[title$="s"] {
            /* 选取属性值以某字符结尾的元素 */
            background-color: hotpink;
        }

        div[title^="s"] {
            /* 选取属性值以某字符开头的元素 */
            border-radius: 3px;
            border: black 1px solid;
        }

        div[title*="a"] {
            /* 选取属性值包含某字符的元素 */
            font-style: italic;
        }
    </style>
</head>

<body>
    <div title="yyy">123</div>
    <div>456</div>
    <div title="zhao">789</div>
    <div>abc</div>
    <div title="yyy">def</div>
    <div title="sakura">def</div>
    <div title="yys">def</div>
    <div title="suzhisanlian">def</div>
    </div>
</body>

</html>